# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=rawr
pkgver=74.544dd75
pkgrel=6
groups=('blackarch' 'blackarch-scanner' 'blackarch-webapp')
pkgdesc='Rapid Assessment of Web Resources. A web enumerator.'
arch=('any')
url='https://bitbucket.org/al14s/rawr/wiki/Home'
license=('GPL3')
makedepends=('git')
depends=('nmap' 'python2' 'graphviz' 'python2-pygraphviz' 'python2-lxml'
         'phantomjs' 'python2-pillow6' 'python2-imaging' 'python2-xlsxwriter'
         'python2-rdpy' 'python2-pyqt4')
source=("git+https://bitbucket.org/al14s/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $pkgname

  sed -i '1s/env python/env python2/' "$pkgname.py"

  #sed -i 's|import Image|from PIL import Image|' lib/functions.py
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 docs/LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
  rm docs/LICENSE
  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname" README.md docs/*

  rm -rf docs/

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 $pkgname.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

